<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>积分规则管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	function change(value){
			
		if(value!=2){
			document.getElementById("div").style.display="none";
			document.getElementById("credit").value="";
		}
			
		
		if(value==2){
			document.getElementById("div").style.display="";
			
		}
	}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/wechat/scoreRule/">积分规则列表</a></li>
		<li class="active"><a href="${ctx}/wechat/scoreRule/form?id=${scoreRule.id}">积分规则<shiro:hasPermission name="wechat:scoreRule:edit">${not empty scoreRule.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="wechat:scoreRule:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="scoreRule" action="${ctx}/wechat/scoreRule/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="user.id"/>
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">名称:</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="11" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">选择积分类型:</label>
			<div class="controls">
				<form:radiobutton path="type" value="0" onclick="change(this.value)"/> 活动送积分&nbsp;<form:radiobutton path="type" value="1" onclick="change(this.value)"/>消费送积分&nbsp;
				<form:radiobutton path="type" value="2" onclick="change(this.value)"/> 充值送积分&nbsp;&nbsp;&nbsp;&nbsp;<label style="color:grey">**PS：送积分类型重复设置的规则以最新设置规则为准</label>
			</div>
		</div>
		<div id="div" style="display:none" class="control-group">
			<label class="control-label">设置充值金额:</label>
			<div class="controls">
				<form:input id="credit" path="money" htmlEscape="false" class="required number"/>
				<label style="color:grey">&nbsp;&nbsp;*以元为单位</label>
			</div>
		</div>
		<div  class="control-group">
			<label class="control-label">设置积分:</label>
			<div class="controls">
				<form:input path="score" htmlEscape="false" class="required number"/>
				<label style="color:grey">&nbsp;&nbsp;**以厘为单位</label>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">备注:</label>
			<div class="controls">
				<form:textarea path="remarks" rows="8"/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="wechat:scoreRule:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
